package top.superflow.version.db.compare

import top.superflow.exception.RequestUnsupportedException
import top.superflow.version.compare.suggestion.{Cause, SuggestedAction, Suggestion}

import scala.collection.mutable.ListBuffer

class MetadataConsistencySuggestion(theCause : Cause, theSuggestedAction : SuggestedAction) extends Suggestion{
  
  private val suggestions : ListBuffer[Suggestion] = ListBuffer()
  private val cause : Cause = theCause
  private val suggestedAction = theSuggestedAction
  
  
  def getFinalSuggestion : List[Suggestion] = {
    suggestions.toList
  }
  
  def addSuggestion(newSuggestion : Any) {
    newSuggestion match {
      case suggestionOption : Option[_] => {
        this.addSuggestion(suggestionOption.get)
      }
      
      case suggestion : Suggestion => {
        suggestions += suggestion
      }
      
      case suggestionList : List[_] => {
        for(suggestion <- suggestionList){
          addSuggestion(suggestion)
        }
      }
      
      case _ => {
        throw new RequestUnsupportedException(newSuggestion)
      }
    }
  }
  
  def getCause : Option[Cause] = {
    Some(this.cause)
  }
  
  def getAction : Option[SuggestedAction] = {
    Some(this.suggestedAction)
  }
}


